package vip

import "github.com/beherochuling/beesoft_api/app/model/vip"

// # VIP-工厂

func NewVipFactory() *vipFactory {
	return &vipFactory{}
}

type vipFactory struct {
	relationType uint
	relationId   uint
	productId    uint
	vipType      uint
	logType      uint
}

// ## Getter&Setter

func (v *vipFactory) RelationType() uint {
	return v.relationType
}

func (v *vipFactory) SetRelationType(relationType uint) *vipFactory {
	v.relationType = relationType

	return v
}

func (v *vipFactory) RelationId() uint {
	return v.relationId
}

func (v *vipFactory) SetRelationId(relationId uint) *vipFactory {
	v.relationId = relationId

	return v
}

func (v *vipFactory) ProductId() uint {
	return v.productId
}

func (v *vipFactory) SetProductId(productId uint) *vipFactory {
	v.productId = productId

	return v
}

func (v *vipFactory) VipType() uint {
	return v.vipType
}

func (v *vipFactory) SetVipType(vipType uint) *vipFactory {
	v.vipType = vipType

	return v
}

func (v *vipFactory) LogType() uint {
	return v.logType
}

func (v *vipFactory) SetLogType(logType uint) *vipFactory {
	v.logType = logType

	return v
}

// ## NewVip

func (v *vipFactory) NewVip() {
	switch v.vipType {
	case vip.VipTypeQuota:
	case vip.VipTypePeriod:
	case vip.VipTypeCandy:
	case vip.VipTypeLimit:
	default:
		panic("vipType is invalid")
	}

	switch v.relationType {
	case vip.RelationTypeUser:
		NewVipUser().
			SetRelationType(v.relationType).
			SetRelationId(v.relationId).
			SetProductId(v.productId).
			SetVipType(v.vipType).
			SetLogType(v.logType)

	case vip.RelationTypeDevice:
		NewVipDevice().
			SetRelationType(v.relationType).
			SetRelationId(v.relationId).
			SetProductId(v.productId).
			SetVipType(v.vipType).
			SetLogType(v.logType)

	case vip.RelationTypeGroup:
		NewVipGroup().
			SetRelationType(v.relationType).
			SetRelationId(v.relationId).
			SetProductId(v.productId).
			SetVipType(v.vipType).
			SetLogType(v.logType)

	default:
		panic("relationType is invalid")
	}
}
